home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / nfsrc21.zip / SETDATE.PRG < prev    next >
Text File  |  1991-08-15  |  3KB  |  102 lines

  1. /*
  2.  * File......: SETDATE.PRG
  3.  * Author....: Glenn Scott
  4.  * CIS ID....: 71620,1521
  5.  * Date......: $Date:   15 Aug 1991 23:04:36  $
  6.  * Revision..: $Revision:   1.3  $
  7.  * Log file..: $Logfile:   E:/nanfor/src/setdate.prv  $
  8.  * 
  9.  * This is an original work by Glenn Scott and is placed in the
  10.  * public domain.
  11.  *
  12.  * Modification history:
  13.  * ---------------------
  14.  *
  15.  * $Log:   E:/nanfor/src/setdate.prv  $
  16.  * 
  17.  *    Rev 1.3   15 Aug 1991 23:04:36   GLENN
  18.  * Forest Belt proofread/edited/cleaned up doc
  19.  * 
  20.  *    Rev 1.2   14 Jun 1991 19:52:58   GLENN
  21.  * Minor edit to file header
  22.  * 
  23.  *    Rev 1.1   12 Jun 1991 02:32:28   GLENN
  24.  * Documentation mod and change documented return value from "n" to "l"
  25.  * reflecting Ted's update of ft_int86().
  26.  * 
  27.  *    Rev 1.0   01 Apr 1991 01:02:16   GLENN
  28.  * Nanforum Toolkit
  29.  *
  30.  */
  31.  
  32.  
  33. /*  $DOC$
  34.  *  $FUNCNAME$
  35.  *     FT_SETDATE()
  36.  *  $CATEGORY$
  37.  *     DOS/BIOS
  38.  *  $ONELINER$
  39.  *     Set the DOS system date
  40.  *  $SYNTAX$
  41.  *     FT_SETDATE( <dDate> ) -> <lResult>
  42.  *  $ARGUMENTS$
  43.  *     <dDate> is a Clipper date variable that you want to set the current
  44.  *     DOS system date to.
  45.  *
  46.  *     It is up to you to send in a valid date.  The 
  47.  *     year must be within the range 1980 through 2099.  If DOS
  48.  *     thinks the date is not valid, it won't change the date.
  49.  *
  50.  *  $RETURNS$
  51.  *     <lResult> is simply the result of FT_INT86(), passed back
  52.  *     to your program.  
  53.  *
  54.  *  $DESCRIPTION$
  55.  *     FT_SETDATE() uses NANFOR.LIB's FT_INT86() function to invoke
  56.  *     the DOS Set Date service (Interrupt 33, service 43).  
  57.  *     
  58.  *  $EXAMPLES$
  59.  *
  60.  *  The following program takes a date from the command line and sets
  61.  *  the DOS system date:
  62.  *
  63.  *   FUNCTION main( cDate )
  64.  *
  65.  *      cDate := iif( cDate == nil, dtoc( date() ), cDate )
  66.  *      QOut( "Setting date to: " + cDate  + "... " )
  67.  *      FT_SETDATE( ctod( cDate ) )
  68.  *      Qout( "Today is now: " + dtoc( date() ) )
  69.  *
  70.  *   RETURN ( nil )
  71.  *
  72.  *  $END$
  73.  */
  74.  
  75. #include "FTINT86.CH"
  76.  
  77. #define DOS        33
  78. #define SETDATE    43
  79.  
  80.  
  81. #ifdef FT_TEST
  82.   FUNCTION MAIN( cDate )
  83.  
  84.      cDate := iif( cDate == nil, dtoc( date() ), cDate )     
  85.      QOut( "Setting date to: " + cDate  + "... " )
  86.      FT_SETDATE( ctod( cDate ) )
  87.      Qout( "Today is now: " + dtoc( date() ) )
  88.  
  89.   return ( nil )
  90. #endif
  91.  
  92. function FT_SETDATE( dDate )
  93.   local aRegs[ INT86_MAX_REGS ]
  94.  
  95.   dDate := iif( valtype(dDate) != "D", date(), dDate )
  96.  
  97.   aRegs[ AX ] = SETDATE * ( 2 ^ 8 )
  98.   aregs[ CX ] = year( dDate )
  99.   aregs[ DX ] = ( month( dDate ) * ( 2 ^ 8 ) )  + day( dDate )
  100.  
  101. return( FT_INT86( DOS, aRegs ) )
  102.